#include "hal.h"
#include "exception.h"


extern void _cdecl kernel_panic(char *fmt,...);

void exception_install()
{
	setvect (0,(void (__cdecl &)(void))divide_by_zero_fault);
	setvect (1,(void (__cdecl &)(void))single_step_trap);
	setvect (2,(void (__cdecl &)(void))nmi_trap);
	setvect (3,(void (__cdecl &)(void))breakpoint_trap);
	setvect (4,(void (__cdecl &)(void))overflow_trap);
	setvect (5,(void (__cdecl &)(void))bounds_check_fault);
	setvect (6,(void (__cdecl &)(void))invalid_opcode_fault);
	setvect (7,(void (__cdecl &)(void))no_device_fault);
	setvect (8,(void (__cdecl &)(void))double_fault_abort);
	setvect (10,(void (__cdecl &)(void))invalid_tss_fault);
	setvect (11,(void (__cdecl &)(void))no_segment_fault);
	setvect (12,(void (__cdecl &)(void))stack_fault);
	setvect (13,(void (__cdecl &)(void))general_protection_fault);
	setvect (14,(void (__cdecl &)(void))page_fault);
	setvect (16,(void (__cdecl &)(void))fpu_fault);
	setvect (17,(void (__cdecl &)(void))alignment_check_fault);
	setvect (18,(void (__cdecl &)(void))machine_check_abort);
	setvect (19,(void (__cdecl &)(void))simd_fpu_fault);
}

void _cdecl divide_by_zero_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("divide by zero fault");
}

void _cdecl single_step_trap(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("single step trap");
}

void _cdecl nmi_trap(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("nmi trap");
}

void _cdecl breakpoint_trap(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("breakpoint trap");
}

void _cdecl overflow_trap(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("overflow trap");
}

void _cdecl bounds_check_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("bounds check fault");
}

void _cdecl invalid_opcode_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("invalid opcode fault");
}

void _cdecl no_device_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("no device fault");
}

void _cdecl double_fault_abort(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("double fault abort");
}

void _cdecl invalid_tss_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("invalid tss fault");
}

void _cdecl no_segment_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("no segment fault");
}

void _cdecl stack_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("stack fault");
}

void _cdecl general_protection_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("general protection fault");
}

void _cdecl page_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("page fault");
}

void _cdecl fpu_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("fpu fault");
}

void _cdecl alignment_check_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("alignment check fault");
}

void _cdecl machine_check_abort(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("machine check abort");
}

void _cdecl simd_fpu_fault(uint32_t eflags,uint32_t cs,uint32_t eip)
{
	kernel_panic("simd fpu fault");
}